package db;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ItemEntity extends Entity {

	public EntityCollection<AttributeEntity> getAttribute() {
		if(_attributes == null){
			_attributes = new EntityCollection<AttributeEntity> ();
			
		}
		return _attributes;
	}

	private EntityCollection<AttributeEntity> _attributes;
	
	public String getName() {
		return _name;
	}

	private String _name;

	@Override
	protected Entity mapToObj(ResultSet rs) {
		ItemEntity ie = new ItemEntity();
		try {
			ie._id = rs.getInt("item_id");
			ie._name = rs.getString("item_name");
		} catch (Exception e) {
			e.printStackTrace();
		}

		return ie;
	}

	@Override
	protected void fillPreparedParams(PreparedStatement ps) {
		try {
			ps.setObject(1, "item_name");
			ps.setObject(2, _name);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected String getIdCol() {
		return "item_id";
	}

	@Override
	protected int getNoCols() {
		return 1;
	}

	@Override
	protected String getTblname() {
		return "items";
	}

}
